Aspects of the present invention relate to electronic devices and such devices with limited or constrained memory for running multiple applications, and more particularly to a method, device and computer program product for class isolation to minimize memory usage.
Mobile devices, such as smart phones, pad computers and the like may store and run multiple applications or apps. New apps are continuously being created that provide various types of features, functions and operations. Users of such mobile devices or platforms often run multiple independent applications or apps simultaneously or within one runtime environment. Running multiple applications within one runtime environment can require a significant amount of memory in a device that may have a limited amount of memory or is memory constrained because of other objects stored on the device, such as digital photographs, videos, music and other software and computer programs.
One example of a programming model that allow the simultaneous execution of several independent applications within one runtime environment is the Java MicroEdition (ME) space, the Mobile Information Device Profile (MIDP), v3.0 (JSR 271) on top of the Connected Limited Device Configuration (CLDC), v1.1.1 (JSR 139). Java is a trademark of Oracle in the United States, other countries or both. Multi-application environments, like the MIDP 3.0 specification, require that every application (MIDlet in the case of MIPD) be run within its own execution environment. Data and classes are not shared with other applications. This includes all system classes, like java.lang.Object or java.lang.System. Classes and their static data are not shared among applications. If a system class has a static variable, the value of that variable might be different between application A and application B. Furthermore, if application A changes the value of the static variable, then application B will not be affected by this change. For example, if an application calls java.lang.System.out.close( ) the print stream to standard out is closed for this application and for this application alone. Output to standard out from the base system or any other application currently running or launched thereafter can still pass through.
In another example, if application code synchronizes (obtains a lock) on a static variable (e.g. java.lang.System.err) then the application should not block another application which tries to obtain a lock on the same static variable.
In a further example, if application code synchronizes on a java.lang.Class instance (e.g. java.lang.Thread.getClass( )) then it can not block another application which tries to obtain a lock on the same class instance. The synchronize keyword on a static method creates such a lock on a class instance.
In the Java programming language, isolation of application classes is achieved with the class loader technique. This solves the static data isolation and name space conflicts for application classes. However, the isolation of shared system classes is still an issue. There is a need for system class isolation in a manner that is effective in terms of memory usage and performance. On some platforms, memory usage is kept to a minimum, particularly on embedded and mobile device platforms. Small differences in memory requirements can make a significant difference in cost savings in relation to the cost of the device.